package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.config.MinioClientConfig;
import com.atguigu.tingshu.album.config.MinioConstantProperties;
import com.atguigu.tingshu.common.result.Result;
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

/***
 * minio上传
 * @RefreshScope 对Nacos出现改变，立刻刷新
 *  @Value("minio.endpointUrl")
 *     private String endPoint;
 */
@Tag(name = "上传管理接口")
@RestController
@RequestMapping("/api/album")

public class FileUploadApiController {
    @Autowired
    MinioClientConfig minioClientConfig;


    @PostMapping("/fileUpload")
    @SneakyThrows
    public Result<String> fileUpload(@RequestParam("file")MultipartFile file){
        return Result.ok(minioClientConfig.fileUpload(file));
    }

}
